package org.example;

import java.util.Scanner;

public class Planeticket {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入机票原价：");
        int ticket = sc.nextInt();
        System.out.println("请输入月份：");
        int month = sc.nextInt();
        System.out.println("请输入舱位:0头等舱 1经济舱");
        int seat = sc.nextInt();
        if ((month > 4 && month < 11)) {
           /* if (seat == 0) {
                System.out.println("头等舱打九折");
                ticket = (int) (ticket * 0.9);
            } else if (seat == 1) {
                System.out.println("经济舱打八折");
                ticket = (int) (ticket * 0.8);
            }*/
            ticket = price(ticket, seat, 0.9, 0.8);
         }else if ((month > 0 && month < 5) || (month > 10 && month < 13)) {
            /*if (seat == 0) {
                System.out.println("头等舱打七折");
                ticket = (int) (ticket * 0.7);
            } else if (seat == 1) {
                System.out.println("经济舱打6.5折");
                ticket = (int) (ticket * 0.65);
            }*/
        ticket = price(ticket, seat, 0.7, 0.65);
         }
        else {
            System.out.println("输入错误");
        }
        System.out.println("机票最终价格为"+ticket);
    }
   //选中代码块ctrl+alt+m 抽取方法
    public static int price(int ticket, int seat, double v0, double v1) {
        if (seat == 0) {
            System.out.println("头等舱打"+v0+"折");
            ticket = (int) (ticket * v0);
        } else if (seat == 1) {
            System.out.println("经济舱打"+v1+"折");
            ticket = (int) (ticket * v1);
        }
        return ticket;
    }
}